package com.maserb.monitor.repository.schoolNotice;

import com.maserb.monitor.entity.schoolNotice.SchoolNoticeHistoryEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SchoolNoticeHistoryRepository extends JpaSpecificationExecutor<SchoolNoticeHistoryEntity>
        , PagingAndSortingRepository<SchoolNoticeHistoryEntity, String> {

    List<SchoolNoticeHistoryEntity> findByUserIdAndNoticeId(String userId,String noticeId);

    @Query(value = "select count(*) from SchoolNoticeHistoryEntity where orgId=?1 and userId=?2 and type=?3 and isRead='0'")
    Integer countByOrgIdAndUserId(String orgId, String userId,String type);

}